fix(core): cap session output tokens#36333
Draft
opencode-agent[bot] wants to merge 1 commit into
Draft
Conversation
This was referenced Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
V2 left
generation.maxTokensunset. Grok 4.5 advertises a 500,000-token context and 500,000-token output limit, so the provider defaulted the request to 500,000 output tokens. Even a freshhisession then requested roughly 500,333 total tokens and failed immediately. Compaction also treated the full 500,000 tokens as reserved output.Source report: https://x.com/dkfiander/status/2075682541026128183
Test plan
bun test test/session-runner.test.ts --filter 'caps output when the catalog output limit consumes the full context window'bun test test/session-compaction.test.ts test/session-runner-model.test.tsbun typecheckfrompackages/coreThe repository-wide pre-push typecheck was attempted but the 3.2 GB host exhausted process resources (
EAGAIN) and Bun crashed while Turbo ran 36 packages concurrently. The affected package typecheck passed independently.